package controllers

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"hr/logic"
	"strconv"
)

func CommunityHandler(c *gin.Context) {
	list, err := logic.GetCommunityList()
	if err != nil {
		zap.L().Error("logic.GetCommunityList() failed", zap.Error(err))
		ResponseError(c, CodeServerBusy) //不要轻易把错误保留给外部
		return
	}
	ResponseSuccess(c, list)
}
func CommunityDeleteHandler(c *gin.Context) {
	idStr := c.Param("id")
	id, err := strconv.ParseInt(idStr, 10, 64)
	if err != nil {
		ResponseError(c, CodeInvalidParam)
		return
	}
	list, err := logic.GetCommunityDetail(id)
	if err != nil {
		zap.L().Error("logic.GetCommunityList() failed", zap.Error(err))
		ResponseError(c, CodeServerBusy) //不要轻易把错误保留给外部
		return
	}
	ResponseSuccess(c, list)
}
